import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';

export default async function a014(fd: IFeidaoAiBrowserComponent,e:Event) {
	// todo
	const question_bank_type1 = fd.data.node.querySelector<HTMLSelectElement>('[data-id="question_bank_type"]');
	const question_bank_type = question_bank_type1.value;
	const topic_type1 = fd.data.node.querySelector<HTMLSelectElement>('[data-id="topic_type"]');
	const topic_type = topic_type1.value;
	const topic1 = fd.data.node.querySelector<HTMLInputElement>('[data-id="topic"]');
	const topic = topic1.value;
	const i = e.currentTarget as HTMLElement;
	const datav = i.getAttribute('data-v');
	const datano = i.getAttribute('data-no');
	if(datano === '0'){
		const res = await nodejs<{d3: Array <{}>}>('question-bank/zj-000001/s006', {
			filter: {
				data_v: datav,
				question_bank_type,
				topic_type,
				topic

			}
		});
		render(fd,res.d3,p001,"p001",'inner');
		i.setAttribute('data-no','1');
	}else{
		const res = await nodejs<{d4:Array<{}>}>('question-bank/zj-000001/s006', {
			filter: {
				data_v: datav,
				question_bank_type,
				topic_type,
				topic

			}
		});
		render(fd,res.d4,p001,"p001",'inner');
		i.setAttribute('data-no','0');
	}


}
